/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: oper.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月22日 星期二 10时41分19秒
***************************************************/

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef unsigned char u8;

class Time {
	u8 hour; // 成员变量默认私有
	u8 min;
	u8 sec;
public:
	Time(u8 _hour, u8 _m, u8 _s)
	{
		hour = _hour;
		min = _m;
		sec = _s;
	}
	void set_time(u8 _hour, u8 _m, u8 _s)
	{
		hour = _hour;
		min = _m;
		sec = _s;
	}
	void output()
	{
		cout << (int)hour << ":" << (int)min << ":" << (int)sec << endl;
	}
	// 成员函数，对于-进行重载(重新定义运算符-的功能)的成员函数
	int operator-(Time &t)
	{
		t.output();
		
		int sec_obj = this->hour * 3600 + this->min * 60 + this->sec;
		int sec_arg = t.hour * 3600 + t.min * 60 + t.sec;
		return sec_obj - sec_arg;
	}
	
};


int main(int argc,const char* argv[])
{
	int a = 10;
	int b = 20;

	int sum = a + b;
	
	Time t1(10,33,20);   // 实例化时间对象，并提供初始值
	Time t2(10,44,10);
	
	//t2.output();
	
	int sec = t2 - t1; // t2.operator-( t1 );
	cout << sec << endl;
    return 0;
}
